<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('信息展示')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="type-form">
					<div class="select-list">
						<ul>
							<li>
								收益调节：<input name="profitAdjust" type="text" id="sytj"/>%
							</li>
							<li>
								嘉奖设置：<input name="rewardSetting" type="text" id="jjsz"/>%
							</li>
							<li>
								竞彩返点：<input name="lotteryRtnWater" type="text" id="lotteryRtnWater"/>
							</li>
							<li>
								HG返点：<input name="peripheryRtnWater" type="text" id="peripheryRtnWater"/>
							</li>
							<li>
								下注金额：<input name="betMoneyWinLose" type="text" id="betMoneyWinLose"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="openDialogTable()"><i class="fa fa-cog"></i>&nbsp;设置</a>
							</li>
							<li>
								<input name="kind1" type="hidden" id="kind1"/>
								<input name="kind2" type="hidden" id="kind2"/>
								<input name="originOddsWinLose1" type="hidden" id="originOddsWinLose1"/>
								<input name="originOddsFlat1" type="hidden" id="originOddsFlat1"/>
								<input name="originOddsPeriphery1" type="hidden" id="originOddsPeriphery1"/>
								<input name="originOddsWinLose2" type="hidden" id="originOddsWinLose2"/>
								<input name="originOddsFlat2" type="hidden" id="originOddsFlat2"/>
								<input name="originOddsPeriphery2" type="hidden" id="originOddsPeriphery2"/>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="col-sm-12 select-table table-striped">
	        	<div class="col-sm-12">
	        		<table id="bootstrap-table1" class="table table-bordered">
	        			<thead>
	        				<tr>
		        				<th></th>
		        				<th>类型</th>
		        				<th>竞彩</th>
		        				<th>平局</th>
		        				<th>外盘</th>
		        				<th>返还率%</th>
		        			</tr>	
	        			</thead>
	        			<tbody>
	        			</tbody>
	        		</table>
	        	</div>
	        	<div class="col-sm-12">
	        		<table id="bootstrap-table"  class="table table-bordered">
	        			<thead>
	        				<tr>
		        				<th></th>
		        				<th>混合赔率</th>
		        				<th>返水</th>
		        				<th>赔率</th>
		        				<th>下注</th>
		        				<th>奖金+嘉奖</th>
		        				<th>平局返水</th>
		        				<th>竞彩返水</th>
		        				<th>外盘返水</th>
		        				<th>总收入</th>
		        				<th>总成本</th>
		        				<th>收益</th>
		        				<th>净收益%</th>
		        			</tr>	
	        			</thead>
	        			<tbody>
	        			</tbody>
	        		</table>
	        	</div>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var requestForm = localStorage.getItem("requestForm");
		var patamTableData = localStorage.getItem("patamTableData");
		var resData = localStorage.getItem("resData");
		var prefix = ctx + "system/manager";
		if(requestForm && patamTableData && resData){
			requestForm = JSON.parse(requestForm);
			patamTableData = JSON.parse(patamTableData);
			resData = JSON.parse(resData);
	        var openDialogTable = function() {
	            var oowL1 = $('#jcfd1');
	            if(!oowL1 || oowL1.length<1) {
	            	oowL1 = null;
	            }else {
	            	oowL1 = oowL1.val();
	            };
	            $('#originOddsWinLose1').val(oowL1);
	            var qqf1 = $('#flat1');
	            if(!qqf1 || qqf1.length<1) {
	            	qqf1 = null;
	            }else {
	            	qqf1 = qqf1.val();
	            };
	            $('#originOddsFlat1').val(qqf1);
	            var oop1 = $('#hgfd1');
	            if(!oop1 || oop1.length<1) {
	            	oop1 = null;
	            }else {
	            	oop1 = oop1.val();
	            };
	            var oowL2 = $('#jcfd2');
	            if(!oowL2 || oowL2.length<1) {
	            	oowL2 = null;
	            }else {
	            	oowL2 = oowL2.val();
	            };
	            $('#originOddsWinLose2').val(oowL2);
	            var qqf2 = $('#flat2');
	            if(!qqf2 || qqf2.length<1) {
	            	qqf2 = null;
	            }else {
	            	qqf2 = qqf2.val();
	            }
	            $('#originOddsFlat2').val(qqf2);
	            var oop2 = $('#hgfd2');
	            if(!oop2 || oop2.length<1) {
	            	oop2 = null;
	            }else {
	            	oop2 = oop2.val();
	            }
	            $('#originOddsPeriphery2').val(oop2);
	            $.table.search();
	        };
			var renderTable = function(result) {
				function renderItem(index) {
					var html = [];
					if(index==0) {
						html.push('<tr>');
						html.push('	<td>竞彩二串一</td>');
						html.push('	<td>'+parseFloat(result.OddsMixedDoubleToOne).toFixed(3)+'</td>');
						html.push('	<td>'+(100*resData.LotteryRtnWater).toFixed(2)+'%</td>');
						html.push('	<td>'+parseFloat(result.OddsDoubleToOne).toFixed(3)+'</td>');
						html.push('	<td><input type="number" style="color:red;width:60px;margin-right:2px;" id="tzje" value="'+result.BetMoneyDoubleToOne+'" /></td>');
						html.push('	<td>'+parseFloat(result.RewordDoubleToOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.FlatRtnDoubleToOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.LotteryRtnDoubleToOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.PeripheryRtnDoubleToOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalIncomeLotteryDobuleToOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalExpenseLotteryDobuleToOne).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.TotalProfitLotteryDobuleToOne).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.ProfitPercentLotteryDobuleToOne).toFixed(2)+'</td>');
						html.push('</tr>');
					}else if(index==1) {
						html.push('<tr>');
						html.push('	<td>第1场外盘</td>');
						html.push('	<td>'+parseFloat(result.OddsMixedPeripheryOne).toFixed(3)+'</td>');
						html.push('	<td>'+(100*resData.PeripheryRtnWater).toFixed(2)+'%</td>');
						html.push('	<td>'+parseFloat(result.OddsPeripheryOne).toFixed(3)+'</td>');
						html.push('	<td>'+parseFloat(result.BetMoneyPeripheryOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.RewordPeripheryOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.FlatRtnPeripheryOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.LotteryPeripheryOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.PeripheryRtnPeripheryOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalIncomePeripheryOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalExpensePeripheryOne).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.TotalProfitPeripheryOne).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.ProfitPercentPeripheryOne).toFixed(2)+'</td>');
						html.push('</tr>');
					}else if(index==2) {
						html.push('<tr>');
						html.push('	<td>第1场平局</td>');
						html.push('	<td>'+parseFloat(result.OddsMixedPeripheryFlatOne).toFixed(3)+'</td>');
						html.push('	<td>'+(100*resData.PeripheryRtnWater).toFixed(2)+'%</td>');
						html.push('	<td>'+parseFloat(result.OddsPeripheryFlatOne).toFixed(3)+'</td>');
						html.push('	<td>'+parseFloat(result.BetMoneyPeripheryFlatOne).toFixed(3)+'</td>');
						html.push('	<td>'+parseFloat(result.RewordPeripheryFlatOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.FlatRtnPeripheryFlatOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.LotteryPeripheryFlatOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.PeripheryRtnPeripheryFlatOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalIncomePeripheryOne).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalExpensePeripheryOne).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.TotalProfitPeripheryOne).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.ProfitPercentPeripheryOne).toFixed(2)+'</td>');
						html.push('</tr>');
					}else if(index==3) {
						html.push('<tr>');
						html.push('	<td>第2场外盘</td>');
						html.push('	<td>'+parseFloat(result.OddsMixedPeripheryTwo).toFixed(3)+'</td>');
						html.push('	<td>'+(100*resData.PeripheryRtnWater).toFixed(2)+'%</td>');
						html.push('	<td>'+parseFloat(result.OddsPeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.BetMoneyPeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.RewordPeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.FlatRtnPeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.LotteryPeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.PeripheryRtnPeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalIncomePeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalExpensePeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.TotalProfitPeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.ProfitPercentPeripheryTwo).toFixed(2)+'</td>');
						html.push('</tr>');
					}else if(index==4) {
						html.push('<tr>');
						html.push('	<td>第2场平局</td>');
						html.push('	<td>'+parseFloat(result.OddsMixedPeripheryFlatTwo).toFixed(3)+'</td>');
						html.push('	<td>'+(100*resData.PeripheryRtnWater).toFixed(2)+'%</td>');
						html.push('	<td>'+parseFloat(result.OddsPeripheryFlatTwo).toFixed(3)+'</td>');
						html.push('	<td>'+parseFloat(result.BetMoneyPeripheryFlatTwo).toFixed(3)+'</td>');
						html.push('	<td>'+parseFloat(result.RewordPeripheryFlatTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.FlatRtnPeripheryFlatTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.LotteryPeripheryFlatTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.PeripheryRtnPeripheryFlatTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalIncomePeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td>'+parseFloat(result.TotalExpensePeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.TotalProfitPeripheryTwo).toFixed(2)+'</td>');
						html.push('	<td style="color:red;">'+parseFloat(result.ProfitPercentPeripheryTwo).toFixed(2)+'</td>');
						html.push('</tr>');
					}
					html = $(html.join('\r\n'));
					return html;
				}
				var c2 = $('#bootstrap-table2').find('tbody');
				c2.empty();
				for(var i=0; i<5; i++) {
					var div = renderItem(i);
					c2.append(div);
				}
			};
			var renderTable1 = function() {
				$('#sytj').val(resData.ProfitAdjust);
				$('#jjsz').val(resData.RewardSetting);
				function renderItem(item, index) {
					var html = [];
					if(index==0) {
						html.push('<tr>');
						html.push('	<td>'+item.title+'</td>');
						html.push('	<td>'+item.type+'</td>');
						html.push('	<td>'+item.jc+'</td>');
						html.push('	<td>'+item.flat+'</td>');
						html.push('	<td>'+item.hg+'</td>');
						html.push('	<td></td>');
						html.push('</tr>');
					}else {
						html.push('<tr>');
						html.push('	<td>'+item.title+'</td>');
						html.push('	<td>'+item.type+'</td>');
						if(item.jc && item.jc!='') {
							var jc = item.jc.split("：");
							html.push('	<td><input type="number" style="color:red;width:60px;margin-right:2px;" id="jcfd'+index+'" value="'+jc[1]+'" />'+jc[0]+'</td>');
						}else {
							html.push('	<td></td>');
						}
						if(item.flat && item.flat!='') {
							var flat = item.flat.split("：");
							html.push('	<td><input type="number" style="color:red;width:60px;margin-right:2px;" id="flat'+index+'" value="'+flat[1]+'" />'+flat[0]+'</td>');
						}else {
							html.push('	<td></td>');
						}
						if(item.hg && item.hg!='') {
							var hg = item.hg.split("：");
							html.push('	<td><input type="number" style="color:red;width:60px;margin-right:2px;" id="hgfd'+index+'" value="'+hg[1]+'" />'+hg[0]+'</td>');
						}else {
							html.push('	<td></td>');
						}
						html.push('	<td>'+item.RewordReturn+'</td>');
						html.push('</tr>');
					}
					html = $(html.join('\r\n'));
					return html;
				}
				var c1 = $('#bootstrap-table1').find('tbody');
				c1.empty();
				for(var i=0; i<patamTableData.length; i++) {
					var div = renderItem(patamTableData[i],i);
					c1.append(div);
				}
			};
			var getRows = function(isReset) {
				var baseUrl = "http://83t95.xyz:8090/api/Double";
				$.operate.post(baseUrl, resData, renderTable, true, isReset);
			}
			$(function() {
				renderTable1();
				//getRows(false);
				$('#kind1').val(resData.Kind1);
	            $('#kind2').val(resData.Kind2);
	            $('#originOddsWinLose1').val(resData.OriginOddsWinLose1);
	            $('#originOddsFlat1').val(resData.OriginOddsFlat1);
	            $('#originOddsWinLose2').val(resData.OriginOddsWinLose2);
	            $('#originOddsFlat2').val(resData.OriginOddsFlat2);
	            $('#originOddsPeriphery1').val(resData.OriginOddsPeriphery1);
	            $('#originOddsPeriphery2').val(resData.OriginOddsPeriphery2);
	            $('#betMoneyWinLose').val(resData.BetMoneyWinLose);
	            $('#lotteryRtnWater').val(resData.LotteryRtnWater);
	            $('#peripheryRtnWater').val(resData.PeripheryRtnWater);
				var options = {
				        url: prefix + "/double",
				        modalName: "二串一",
				        columns: [{
				            field: 'name',
				            title: '',
				        },
				        {
				            field: 'oddsMixed',
				            title: '混合赔率',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(3)
				        	}
				        },
				        {
				            field: 'rtnWater',
				            title: '返水',
				            formatter: function (value, row, index) {
				        		return parseFloat(value)*100+'%';
				        	}
				        },
				        {
				            field: 'odds',
				            title: '赔率',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(3)
				        	}
				        },
				        {
				            field: 'betMoney',
				            title: '下注金额',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(2)
				        	}
				        },
				        {
				            field: 'reword',
				            title: '奖金+嘉奖',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(2)
				        	}
				        },
				        {
				            field: 'flatRtn',
				            title: '平局返水',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(2)
				        	}
				        },
				        {
				            field: 'lotteryRtn',
				            title: '竞彩返水',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(2)
				        	}
				        },
				        {
				            field: 'periphery1Rtn',
				            title: '外盘1返水',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(2)
				        	}
				        },
				        {
				            field: 'periphery2Rtn',
				            title: '外盘2返水',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(2)
				        	}
				        },
				        {
				            field: 'totalIncome',
				            title: '总收入',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(2)
				        	}
				        },
				        {
				            field: 'totalExpense',
				            title: '总成本',
				            formatter: function (value, row, index) {
				        		return parseFloat(value).toFixed(2)
				        	}
				        },
				        {
				            field: 'totalProfit',
				            title: '收益',
				            formatter: function (value, row, index) {
				            	var totalProfit = parseFloat(value).toFixed(2);
				            	if(totalProfit>0) return '<span style="color:red;">'+totalProfit+'</span>'
				        		return '<span style="color:#00CC00;">'+totalProfit+'</span>'
				        	}
				        },
				        {
				            field: 'profitPercent',
				            title: '净收益%',
				            formatter: function (value, row, index) {
				            	var profitPercent = parseFloat(value)*100;
				            	profitPercent = profitPercent.toFixed(2);
				            	if(profitPercent>0) return '<span style="color:red;">'+profitPercent+'%</span>'
				        		return '<span style="color:#00CC00;">'+profitPercent+'%</span>'
				        	}
				        },
				        ]
				    };
				    $.table.init(options);
			});
		}
	</script>
</body>
</html>